<!DOCTYPE html>
<html>
<header>
    
</header>
<body>
    <h1>Workers {% if not dashboard.workers %} (There is no active worker) {% endif %} <a href="/celery_tasks">Go to Tasks Page</a></h1>
    <table>
        <thead>
            <tr>
                <th>
                    Worker
                </th>
                <th>Queues</th>
                <th>Status</th>
                <th>Concurrency</th>
                <th>Broker Transport</th>
                <th>Broker Hostname</th>
                <th>Broker Port</th>
            </tr>
        </thead>
        <tbody>
            {% for worker in dashboard.workers %}
            <tr>
                <td>{{ worker.name }}</td>
                <td>{% for queue in worker.queues %}<li>{{ queue }}</li>{% endfor %}</td>
                <td>{{ worker.status }}</td>
                <td>{{ worker.concurrency }}</td>
                <td>{{ worker.broker.transport }}</td>
                <td>{{ worker.broker.hostname }}</td>
                <td>{{ worker.broker.port }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <h1>Registered Tasks</h1>
    {% if dashboard.registered_tasks.items %}
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Queue</th>
                <th>Operation</th>
            </tr>
        </thead>
        <tbody>
            {% for task,worker in dashboard.registered_tasks.items() %}
            <tr>
                <td>{{ task }}</td>
                <td>{{ worker }}</td>
                <td><input type="submit" value="Execute" onclick="execute('run','{{ task }}')"></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
    <p>无</p>
    {% endif %}
    <h1>Active Tasks</h1>
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Id</th>
                <th>Worker</th>
                <th>Queue</th>
                <th>Operation</th>
            </tr>
        </thead>
        <tbody>
            {% for task in dashboard.queue_tasks.active %}
            <tr>
                <td>{{ task.name }}</td>
                <td>{{ task.id }}</td>
                <td>{{ task.worker }}</td>
                <td>{{ task.queue }}</td>
                <td><input type="submit" value="Revoke" onclick="run('revoke','{{ task.id }}')"></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <h1>Reserved Tasks</h1>
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Id</th>
                <th>Worker</th>
                <th>Queue</th>
                <th>Operation</th>
            </tr>
        </thead>
        <tbody>
            {% for task in dashboard.queue_tasks.reserved %}
            <tr>
                <td>{{ task.name }}</td>
                <td>{{ task.id }}</td>
                <td>{{ task.worker }}</td>
                <td>{{ task.queue }}</td>
                <td>
                    <input type="submit" value="Revoke" onclick="run('revoke','{{ task.id }}')">
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
<script type="text/javascript">
    function execute(command,parameter){
        var url="/celery_operation";
        url+="?command="+command+"&parameter="+parameter;
        var a=document.createElement('a');
        a.href=url;
        document.body.appendChild(a);
        a.click();
    }
</script>
</body>
</html>